package cn.zhoujing.demo.redis.handler;

import cn.zhoujing.demo.redis.common.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理类
 *
 * @author zhoujing
 * @createTime 2023/12/3 - 13:48
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public CommonResult globalExceptionHandler(Exception e) {
        log.error("[全局异常捕获]异常信息：" + e);
        e.printStackTrace();
        return CommonResult.failed();
    }


}
